/**
 * 存储localStorage
 */
export const setStore = (name, content) => {
  if (!name) return;
  if (typeof content !== "string") {
    content = JSON.stringify(content);
  }
  window.localStorage.setItem(name, content);
};

/**
 * 获取localStorage
 */
export const getStore = name => {
  if (!name) return;
  return window.localStorage.getItem(name);
};

/**
 * 删除localStorage
 */
export const removeStore = name => {
  if (!name) return;
  window.localStorage.removeItem(name);
};

/**
 * 判断是否过期
 */
export const isExpired = date => {
  if (!new Date(date).getTime()) {
    return false;
  }
  let expiredDate = new Date(date).getTime();
  let nowDate = new Date().getTime();
  if (nowDate > expiredDate) {
    //过期返回true
    return true;
  } else {
    return false;
  }
};

export default {
  Page :{
    //打开新窗口
    OpenNewTab: function (_Url, _Param) {
      window.open(_Url + (_Param ? ('?' + _Param) : ''), '_blank');
    },
    //打开新页面
    OpenNewPage: function (_Url, _Param) {
      window.open(_Url + (_Param ? ('?' + _Param) : ''), "_blank", "scrollbars=yes,resizable=1,modal=false,alwaysRaised=yes");
    }
  }
}